package com.leetcode.partition4;

import com.leetcode.common.ListNode;

import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * @author `RKC`
 * @date 2022/1/16 9:26
 */
public class LC382链表随机节点 {

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String[] s = reader.readLine().split("\\s+");
        writer.flush();
    }

    private static class Solution {

        private List<Integer> nums = new ArrayList<>();

        public Solution(ListNode head) {
            ListNode curr = head;
            while (curr != null) {
                nums.add(curr.val);
                curr = curr.next;
            }
        }

        public int getRandom() {
            Random random = new Random();
            return nums.get(random.nextInt(nums.size()));
        }
    }
}
